﻿using System.Linq;
using DataObjects;
using DreamDriven.ObjectModel.Contracts;
using DreamDriven.ObjectModel.DataAccess;

namespace DataAccess
{
    /// <summary>
    /// Represents Repository of DataObject
    /// </summary>
    public sealed class Repository : DomainRepository<DataObject>
    {
        public Repository(IDomainModel domainModel)
            : base(domainModel)
        {
        }

        /// <summary>
        /// Gets the name of the data object.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <returns></returns>
        public DataObject GetDataObjectByName(string name)
        {
            var query = from dataObject in Collection
                        where name.Equals(dataObject.Name)
                        select dataObject;
            return query.FirstOrDefault();
        }
    }
}
